package com.sc.nft.admin.controller;


import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.sc.nft.dao.MetaMapSettleDao;
import com.sc.nft.entity.dto.SaasTaskBurialPointDTO;
import com.sc.nft.enums.MessageTopic;
import com.sc.nft.helper.MessageQueueHelper;
import com.sc.nft.service.UserWalletService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (ActivityAward)表控制层
 *
 * @author 王伟成
 * @since 2023-09-13 16:16:52
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/activityAward")
@Api(tags = "")
public class ActivityAwardController {
    /**
     * 服务对象
     */

    private final MessageQueueHelper messageQueueHelper;

    private final MetaMapSettleDao metaMapSettleDao;
    private final UserWalletService userWalletService;


        @ApiOperation(value = "补发", notes = "补发", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/reissue", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result reissue() throws Exception {
            SaasTaskBurialPointDTO saasTaskBurialPointDTO = new SaasTaskBurialPointDTO();
            messageQueueHelper.sendMessage(MessageTopic.DISK_TAKER,
                    JSONObject.parseObject(StrUtil.format(
                            "{\"userId\":42874,\"taskType\":\"PASSIVITY_INVITE_SMELTING_APPOINT_COLLECTION\",\"schedule\":2,\"voluntarySum\":1,\"conditionId\":600,\"orderId\":703,\"valid\":null,\"saasTaskMeetConditionsLocationEnum\":null}"), SaasTaskBurialPointDTO.class),"PASSIVITY_INVITE_SMELTING_APPOINT_COLLECTION","115650:674:PASSIVITY_INVITE_SMELTING_APPOINT_COLLECTION");

            return Result.success();
    }
//
//    @ApiOperation(value = "task定时测试", notes = "task定时测试", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @PostMapping(value = "/test", produces = MediaType.APPLICATION_JSON_VALUE)
//    public Result test() throws Exception {
//        metaMapSettleDao.getShareProfitList().forEach(userWalletService::mapShareProfit);
//        return Result.success();
//    }


//    @ApiOperation(value = "补发", notes = "补发", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @PostMapping(value = "/reissue", produces = MediaType.APPLICATION_JSON_VALUE)
//    public Result reissue() throws Exception {
//        for (Long o :reissueUserId()) {
//            messageQueueHelper.sendMessage(MessageTopic.DISK_TAKER,
//                    JSONObject.parseObject(StrUtil.format(
//                            "{\"userId\":{},\"taskType\":\"ACCUMULATED_CONSUMPTION_AMOUNT\",\"schedule\":2888.00,\"voluntarySum\":0,\"conditionId\":7875,\"orderId\":165170,\"valid\":null,\"saasTaskMeetConditionsLocationEnum\":\"MALL\"}",o), SaasTaskBurialPointDTO.class),"ACCUMULATED_CONSUMPTION_AMOUNT","123");
//        }
//        return Result.success();
//    }
//
//    public static List<Long> reissueUserId(){
//        // 创建集合来存储id
//        List<Long> ids = new ArrayList<>();
//
//        // 读取文件并将每一行的id存入集合中
//        try {
//            File file = new File("C:\\Users\\PC\\Desktop\\reissueUserId.txt");
//            Scanner scanner = new Scanner(file);
//            while (scanner.hasNextLine()) {
//                String id = scanner.nextLine().trim();
//                // 添加非空id到集合中
//                if (!id.isEmpty()) {
//                    ids.add(Convert.toLong(id));
//                }
//            }
//            scanner.close();
//        } catch (FileNotFoundException e) {
//            System.out.println("文件未找到: " + e.getMessage());
//        }
//        System.err.println(ids);
//        return ids;
//    }
}
